/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import Server.BUS.StringUlti;
import Server.DTO.SelectHaveWhereQuery;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author Trung
 */
public class SelectHaveWhereQueryTest {
    
    public SelectHaveWhereQueryTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    @Test
    public void testSelectHaveWhereQueryContructor1() {
        // TODO review the generated test code and remove the default call to fail.
        String queryString = "SELECT a.ID, a.NAME FROM TableA a, TableB b WHERE a.ID = b.ID";
        queryString = StringUlti.formatString(queryString);
        
        SelectHaveWhereQuery shw = new SelectHaveWhereQuery(queryString);
        
        assertTrue(shw.queryString.equalsIgnoreCase(queryString));
        assertTrue(shw.keyWord.equalsIgnoreCase("SELECT_HAVEWHERE"));
        assertTrue(shw.selectString.equalsIgnoreCase("a.ID, a.NAME"));
        assertTrue(shw.fromString.equalsIgnoreCase("TableA a, TableB b"));
        assertTrue(shw.getWhereString().equalsIgnoreCase("a.ID = b.ID"));
    }
    
    @Test
    public void testSelectHaveWhereQueryContructor2() {
        // TODO review the generated test code and remove the default call to fail.
        String queryString = "   SELECT     a.ID, a.NAME    FROM TableA a, TableB b    WHERE a.ID = b.ID   ";
        queryString = StringUlti.formatString(queryString);
        
        SelectHaveWhereQuery shw = new SelectHaveWhereQuery(queryString);
        
        assertTrue(shw.queryString.equalsIgnoreCase(queryString));
        assertTrue(shw.keyWord.equalsIgnoreCase("SELECT_HAVEWHERE"));
        assertTrue(shw.selectString.equalsIgnoreCase("a.ID, a.NAME"));
        assertTrue(shw.fromString.equalsIgnoreCase("TableA a, TableB b"));
        assertTrue(shw.getWhereString().equalsIgnoreCase("a.ID = b.ID"));
    }
}
